import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const ContractAbout = {
    namespaced: true,
    actions:{
        //保存合同条款
        save_items(context,item){
            context.commit("SAVE_ITEMS",item)
        },
        //保存合同行
        save_line(context,item) {
            context.commit("SAVE_LINE",item)
        },
        //存入合同行
        push_line(context,item) {
            context.commit("PUSH_LINE",item)
        }
    },
    mutations:{
        SAVE_ITEMS(state,item){
            state.contract.contractTerms = item
        },
        SAVE_LINE(state,item){
            state.contractDetail = item
        },
        PUSH_LINE(state,item){
            console.log(item)
            state.contract.contractDetailList.push(item);
            for (let key in state.contractDetail) {
                state.contractDetail[key] = ""; // 或者根据实际情况赋值为其他默认值
            }
        }
    },
    state:{
        //合同条款
        // contractTerms: {
        //     paymentMethodTerms: "",
        //     paymentMethodTermsContent: "",
        //     paymentMethodTermsParam: "",
        //     deliveryTerms: "",
        //     deliveryTermsContent: "",
        //     deliveryTermsParam: "",
        //     transportTerms: "",
        //     transportTermsContent: "",
        //     transportTermsParam: "",
        //     supplierEmail: "",
        //     customerEmail: "",
        //     deliveryDateTerms: "",
        //     deliveryDateTermsContent: "",
        //     dateParamFrom: "",
        //     dateParamTo: "",
        //     specialTerms: "",
        //     specialTermsContent: "",
        //     param1: "",
        //     param2: "",
        //     param3: "",
        // },
        //合同行
        // contractDetailList:[],
        contract: {
            contractNum: "",
            status: "",
            salesman: "",
            businessType: "",
            contractTemplate:"",
            contractType:"",
            manageCategory:"",
            customerName:"",
            salesDept:"",
            salesCustomerService:"",
            effectiveDateFrom:"",
            effectiveDateTo:"",
            planPaymentDate:"2023-10-01",
            remark:"",
            contractDetailList:[],
            contractTerms:{
                paymentMethodTerms: "",
                paymentMethodTermsContent: "",
                paymentMethodTermsParam: "",
                deliveryTerms: "",
                deliveryTermsContent: "",
                deliveryTermsParam: "",
                transportTerms: "",
                transportTermsContent: "",
                transportTermsParam: "",
                supplierEmail: "",
                customerEmail: "",
                deliveryDateTerms: "",
                deliveryDateTermsContent: "",
                dateParamFrom: "",
                dateParamTo: "",
                specialTerms: "",
                specialTermsContent: "",
                param1: "",
                param2: "",
                param3: "",
            }
        }
    }
}

export const store = new Vuex.Store({
    modules: {
        ContractAbout
    }
})
